package com.woniuxy.dr_mall.entity;



import com.woniuxy.dr_mall.global.ResponseStateCode;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class MyResponseEntity<T> {
    private int code;
    private String msg;
    private T data;

    public static final MyResponseEntity<String> SUCCESS = new MyResponseEntity<>(ResponseStateCode.SUCCESS, "success", "成功");
    public static final MyResponseEntity<String> FAILED = new MyResponseEntity<>(ResponseStateCode.FAILED, "failed", "失败");
    public static final MyResponseEntity<String> FORBIDDEN = new MyResponseEntity<>(ResponseStateCode.FORBIDDEN, "forbidden", "禁止访问");
    public static final MyResponseEntity<String> INVALIDARG = new MyResponseEntity<>(ResponseStateCode.INVALID_ARG, "invalid", "无效参数");
    public static final MyResponseEntity<String> PASSWORD_ERROR = new MyResponseEntity<>(ResponseStateCode.PASSWORD_ERROR, "wrong", "密码错误");
    public static final MyResponseEntity<String> VALUE_EXCEEDS = new MyResponseEntity<>(ResponseStateCode.VALUE_EXCEEDS, "exceeds", "数值超出");
    public static final MyResponseEntity<String> NO_DATA = new MyResponseEntity<>(ResponseStateCode.NO_DATA, "nodata", "无数据");

    public MyResponseEntity() {

    }

    public MyResponseEntity(int state, String msg) {
        this.code = state;
        this.msg = msg;
    }

    public MyResponseEntity(int state, String msg, T data) {
        this(state, msg);
        this.data = data;
    }

    public MyResponseEntity(T data) {
        this.code=200;
        this.msg="ok";
        this.data = data;
    }
}